package com.stm.bi.web;

import com.stm.bi.dto.query.ChartReportQry;
import com.stm.bi.dto.query.DetailChartReportQry;
import com.stm.bi.dto.query.TableReportQry;
import com.stm.bi.model.Chart;
import com.stm.bi.model.DatatablePage;
import com.stm.bi.service.ProductTrendService;
import com.stm.framework.annotation.Module;
import com.stm.framework.annotation.RestApi;
import com.stm.framework.dto.Response;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/productTrend")
@Module("商品推移")
public class ProductTrendController {

    @Resource
    private ProductTrendService productTrendService;

    @PostMapping(value = "/prodData/processChart")
    @RestApi(name = "商品推移-合计推移图",author = "阿俊",idx=1)
    public Response<Chart<List<List<Object>>>> selectChart(@RequestBody ChartReportQry qry){
        return productTrendService.queryChart(qry);
    }

    @PostMapping(value = "/prodData/processDetailChart")
    @RestApi(name = "商品推移-推移明细图",author = "阿俊",idx=2)
    public Response<Chart<List<List<Object>>>> selectDetailChart(@RequestBody DetailChartReportQry qry){
        return productTrendService.queryDetailChart(qry);
    }

    @PostMapping(value = "/prodData/table")
    @RestApi(name = "商品推移-推移表",author = "阿俊",idx=3)
    public Response<DatatablePage> selectTable(@RequestBody TableReportQry qry){
        return productTrendService.queryTable(qry);
    }

    @PostMapping(value = "/prodData/export")
    @RestApi(name = "商品推移-导出",author = "wsb",idx=4)
    public void export(HttpServletResponse response, @RequestBody TableReportQry qry) throws IOException {
        productTrendService.export(response, qry);
    }

}
